package liangtWorkSpace.threadDemo.thread;

import lombok.SneakyThrows;

import java.util.Random;

/**
 * @author liangt
 * @ClassName: Match2
 * @title: Match2
 * @projectName liangtWorkSpace.threadDemo.thread
 * @description: TODO
 * @date 2020/11/3 11:46
 */
public class Match2{

    public static void main(String[] args) {
        Runner liuxiang = new Runner();
        Runner zhangsan = new Runner();
        Runner lisi = new Runner();
        liuxiang.setName("刘翔");
        zhangsan.setName("张三");
        lisi.setName("李四");
        liuxiang.start();
        lisi.start();
        zhangsan.start();
    }
}

class Runner extends Thread{
    @SneakyThrows
    @Override
    public void run(){
        Integer speed = new Random().nextInt(100);
        for (int i = 0; i < 100 ; i++){
            Thread.sleep(10);
            System.out.println(this.getName() + "跑了"+speed*i+"米（"+speed+"米/秒）");
        }
    }
}
